package cn.slipi.admin.common.handler.meta;

import cn.slipi.admin.common.utils.DateUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @author litao
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setInsertFieldValByName("createdAt", DateUtil.getTimeByMinSecond(), metaObject);
        this.setInsertFieldValByName("updatedAt", DateUtil.getTimeByMinSecond(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setUpdateFieldValByName("updatedAt", DateUtil.getTimeByMinSecond(), metaObject);
    }
}
